import { ThemeEnum } from "@/enums/appEnum";
import { darkMode } from "@/settings/designSetting";
import { defineStore } from "pinia";
import { computed, ref, unref, watch } from "vue";
import { store } from "..";

interface AppState {
  darkMode?: ThemeEnum;
}

export const useAppStore = defineStore("app", {
  state: (): AppState => {
    return {
      darkMode: ThemeEnum.DARK,
    };
  },
  getters: {
    getDarkMode(): "light" | "dark" | string {
      return this.darkMode || darkMode;
    },
  },
  actions: {
    setDarkMode(mode: ThemeEnum) {
      this.darkMode = mode;
      console.log(this.darkMode);
    },
  },
});

// 在setup外使用，例如路由的导航守卫
export function useAppStoreWithOut() {
  return useAppStore(store);
}
